{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=205
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	i,j,ii,n,ans:longint;
	a,d:array[0..100010] of longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i:=1 to n do begin 
	read(a[i]);
	d[i]:=1;
end;
ans:=0;
for i:=2 to n do begin
	ii:=i-1;
	for j:=1 to ii do 
		if (a[j] < a[i]) and (d[j]+1 > d[i]) then
			d[i]:=d[j]+1;
end;			
for i:=1 to n do
	ans:=max(ans,d[i]);
write(ans);
end.